import React,{Component}  from 'react'

import Demo04_children from './Demo04_children'
import Demo06 from './Demo06_children_input'

export default class Demo03_live extends Component {
  constructor(props){
    super(props)
    console.log(props);
    this.state={
      val:1
    }
    this.handleClick = this.handleClick.bind(this);
    this.rvcMsg = this.rvcMsg.bind(this);
  }
  handleClick(){
    //console.log(this.val);
    var val =this.state.val
    val++;
    console.log(val)
    this.setState({
      val:val
    })
  }
  rvcMsg = function(msg){
    console.log('父组件接收到的数据是'+msg);
    this.setState({val:msg})
  }
  render(){
    return (
        <div className="father_container">
          <h1>父组件中的子组件</h1>
          <p>子更改父的state数据 {this.state.val}</p>
          <button onClick={this.handleClick}>父组件中点击事件</button>
          <Demo04_children  fun={this.rvcMsg}  title={this.state.val}/>
          <h1>子组件中的input</h1>
          <Demo06/>
        </div>
    );
  }
}